<!DOCTYPE html>
<html lang="en">
<head>
  <title>Document</title>
</head>
<body>
  <style>
    [v-cloak] {
      display: none;
    }
  </style>
  <div id="app">
    <p ref="reference">ref的使用</p>
    <button @click="hint">提示</button>
    <!-- 没有解析之前匹配到v-cloak不显示 解析之后无法匹配到v-cloak显示 -->
    <p v-cloak>{{msg}}</p>

    <p v-upper-text="msg"></p>
    <p v-lower-text="msg"></p>
  </div>
  <script src="./vue.js"></script>
  <script>
    Vue.directive('upper-text', function (el, binding) {
      el.innerHTML = binding.value.toUpperCase()
    })
    // 数据渲染到页面之前会闪现 突出闪现效果
    // alert('---')
    new Vue({
      el: '#app',
      data: {
        msg: 'A day an apple doctor far away'
      },
      methods: {
        hint() {
          alert(this.$refs.reference.innerText)
        }
      },
      directives: {
        'lower-text': {
          bind(el, binding) {
            el.innerHTML = binding.value.toLowerCase()
          }
        }
      }
    })
  </script>
</body>
</html>